//package com.hivision.controller.Energy;
//
//import com.hivision.alimqttapi.entity.TechnicalAttribute;
//import com.hivision.iot.api.AliReqClient;
//import com.hivision.iot.dto.AttributeValueRequestDTO;
//import com.hivision.mapper.TechnicalAttributeMapper;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.math.BigDecimal;
//import java.time.ZoneId;
//import java.time.ZonedDateTime;
//import java.time.format.DateTimeFormatter;
//import java.util.Arrays;
//import java.util.List;
//import java.util.Random;
//
//
//@RequestMapping("/electricity")
//@RestController
//public class electricity {
//    @Autowired
//    private AliReqClient reqClient;
//    @Autowired
//    TechnicalAttributeMapper technicalAttributeMapper;
//
//    List<String> list = Arrays.asList("electricity1","electricity2","electricity3","electricity4","electricity5","electricity6",
//            "electricity7","electricity8","electricity9","electricity10","electricity11","electricity12","electricity13","electricity14",
//            "electricity15","electricity16","electricity17","electricity18","electricity19","electricity20","electricity21","electricity22",
//            "electricity23","electricity24","electricity25","electricity26","electricity27","electricity28","electricity29","electricity30",
//            "electricity31","electricity32","electricity33","electricity34","electricity35","electricity36","electricity37","electricity38",
//            "electricity39","electricity40","electricity41","electricity42","electricity43","electricity44","electricity45","electricity46",
//            "electricity47","electricity48","electricity49","electricity50","electricity51","electricity52","electricity53","electricity54",
//            "electricity55","electricity56","electricity57","electricity58","electricity59","electricity60","electricity61","electricity62",
//            "electricity63","electricity64","electricity65","electricity66","electricity67","electricity68","electricity69","electricity70",
//            "electricity71","electricity72","electricity73","electricity74","electricity75","electricity76","electricity77","electricity78",
//            "electricity79","electricity80","electricity81","electricity82","electricity83","electricity84","electricity85","electricity86",
//            "electricity87","electricity88");
//
//    @Scheduled(cron="0 */1 * * * ?")
//    @GetMapping("write")
//    public void writeValue(){
//        for (String s : list) {
//            // 获取当前系统的日期时间，考虑到时区
//            ZonedDateTime now = ZonedDateTime.now(ZoneId.of("Asia/Shanghai"));
//            // 创建一个日期时间格式器，匹配所需的格式
//            DateTimeFormatter formatter = DateTimeFormatter.ISO_ZONED_DATE_TIME;
//            // 格式化当前日期时间为字符串
//            String formattedNow = now.format(formatter);
//            TechnicalAttribute technicalAttribute1 = new TechnicalAttribute();
//            technicalAttribute1.setAttributeGroupName(s);
//            technicalAttribute1.setAttributeCode("electric_Ep");
//            BigDecimal randomFloat = technicalAttributeMapper.selectTechnicalAttributeList(technicalAttribute1).add(new BigDecimal("0.1"));
//            AttributeValueRequestDTO attributeValueRequestDTO = new AttributeValueRequestDTO();
//            attributeValueRequestDTO.setAssetCode(s);
//            attributeValueRequestDTO.setAttributeCode("electric_Ep");
//            attributeValueRequestDTO.setValue(String.valueOf(randomFloat));
//            reqClient.patchAttributeValue(attributeValueRequestDTO);
//            TechnicalAttribute technicalAttribute=new TechnicalAttribute();
//            technicalAttribute.setWritable("t");
//            technicalAttribute.setMeasureUni("无");
//            technicalAttribute.setMinValue("min无");
//            technicalAttribute.setMaxValueNew("max无");
//            technicalAttribute.setAssetCode("electricity");
//            technicalAttribute.setAttributeName("有功电能");
//            technicalAttribute.setDataTypeNew("Double");
//            technicalAttribute.setAttributeGroupName(s);
//            technicalAttribute.setAttributeCode("HW_TQ");
//            technicalAttribute.setAttributeDescs("无");
//            technicalAttribute.setAttributeGroupDescs("无");
//            technicalAttribute.setEnumValue(String.valueOf(randomFloat));
//            technicalAttribute.setPrecisionNew(36L);
//            technicalAttribute.setCreatedAt(formattedNow);
//            technicalAttribute.setModifiedAt(formattedNow);
//            technicalAttributeMapper.insertTechnicalAttribute(technicalAttribute);
//        }
//    }
//}
